package com.haoze.nurseapp.controller;

import com.haoze.common.response.Result;
import com.haoze.nurseapp.model.AtomizeMedReturnEntity;
import com.haoze.nurseapp.service.AtomizeMedService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Author: Chenchao
 * @CreateTime: 2020-11-25 08:23
 */
@RestController
@RequestMapping(value = "/atomizeMed")
@Api(value = "口服药接口")
public class AtomizeMedController {

    @Autowired
    private AtomizeMedService atomizeMedService;

    @GetMapping("/taskList")
    @ApiOperation(value = "任务执行列表")
    public Result taskList(@RequestParam(required = false) String wardId, @RequestParam(defaultValue = "1") String type, @RequestParam(required = false) String date,
                           @RequestParam(required = false) String queryString, @RequestParam(defaultValue = "1") Integer page
            , @RequestParam(defaultValue = "20") Integer pageSize) {
        return atomizeMedService.taskList(wardId, type, date, queryString, page, pageSize);
    }

    @GetMapping("/numList")
    @ApiOperation(value = "任务执行列表数量")
    public Result numList(@RequestParam(required = false) String wardId, @RequestParam(required = false) String date) {
        return atomizeMedService.numList(wardId, date);
    }

    @PostMapping("/stopTask")
    @ApiOperation(value = "没有生成任务时终止任务")
    public Result stopTask(@RequestBody AtomizeMedReturnEntity atomizeMedReturn) {
        return atomizeMedService.stopTask(atomizeMedReturn);
    }
}
